import axios from '@/libs/api.request'

export const getTableData = () => {
  return axios.request({
    url: 'get_table_data',
    method: 'get'
  })
}

export const getDragList = () => {
  return axios.request({
    url: 'get_drag_list',
    method: 'get'
  })
}

export const errorReq = () => {
  return axios.request({
    url: 'error_url',
    method: 'post'
  })
}

export const saveErrorLogger = info => {
  return axios.request({
    url: 'save_error_logger',
    data: info,
    method: 'post'
  })
}

export const uploadImg = formData => {
  return axios.request({
    url: 'image/upload',
    data: formData
  })
}

export const getOrgData = () => {
  return axios.request({
    url: 'get_org_data',
    method: 'get'
  })
}

export const getTreeSelectData = () => {
  return axios.request({
    url: 'get_tree_select_data',
    method: 'get'
  })
}

export const getTreeTableData = () => {
  return axios.request({
    url: 'get_tree_table_data',
    method: 'get'
  })
}

export const getLinesData = () => {
  return axios.request({
    url: 'get_driver_lines_data',
    method: 'get'
  })
}


export const getHelloData = () => {
  return axios.request({
    url: '/getHello',
    method: 'get'
  })
}


export const getOrganizationalStructure = (query) => {
  return axios.request({
    url: '/getOrganizationalStructure',
    method: 'get',
    params: {
      departmentName: query.name,
      status: query.state
    }
  })
}


export const getTeamPersonnel = (query) => {
  return axios.request({
    url: '/getTeamPersonnel',
    method: 'post',
    data: {
      department: query.department,
      employeeName: query.employeeName,
      status: query.status,
      page: query.page,
      limit: query.limit
    }
  })
}


export const getRolePersonnelList = (query) => {
  return axios.request({
    url: '/getRolePersonnelList',
    method: 'post',
    data: {
      department: query.department,
      role: query.role,
      status: query.status,
      page: query.page,
      limit: query.limit
    }
  })
}


export const getAllDepartmentTreeData = () => {
  return axios.request({
    url: '/getAllDepartmentTreeData',
    method: 'get',
  })
}

export const getAllDepartmentTreeImgData = () => {
  return axios.request({
    url: '/getAllDepartmentTreeImgData',
    method: 'get',
  })
}

export const getAllDepartment_ = () => {
  return axios.request({
    url: '/getAllDepartment',
    method: 'get',
  })
}

export const getAllRole_ = () => {
  return axios.request({
    url: '/getAllRole',
    method: 'get',
  })
}

export const addEmployee = (formItem) => {
  return axios.request({
    url: '/addEmployee',
    method: 'post',
    data: {
      name: formItem.name,
      account: formItem.account,
      uroleId: formItem.uroleId,
      password: formItem.password,
      numberId: formItem.numberId,
      sex: formItem.sex,
      phone: formItem.phone,
      email: formItem.email,
      birth: formItem.birth,
      status: formItem.status,
      corganId: formItem.corganId,
    },
  })
}


export const getEmployeeInfoByAccount = (account) => {
  return axios.request({
    url: '/getEmployeeInfoByAccount',
    method: 'get',
    params: {
      account: account
    },
  })
}

export const updateEmployee = (formItem) => {
  return axios.request({
    url: '/updateEmployee',
    method: 'post',
    data: {
      name: formItem.name,
      account: formItem.account,
      uroleId: formItem.uroleId,
      password: formItem.pwd,
      numberId: formItem.idCard,
      sex: formItem.sex,
      phone: formItem.phone,
      email: formItem.email,
      birth: formItem.birth,
      status: formItem.status,
      corganId: formItem.corganId,
    },
  })
}

export const getCarList = (query) => {
  return axios.request({
    url: '/getCarList',
    method: 'post',
    data: {
      carLicense: query.carId,
      status: query.status,
      page: query.page,
      limit: query.limit
    }
  })
}


export const getCarById = (dccarId) => {
  return axios.request({
    url: '/getCarById',
    method: 'get',
    params: {
      "dccarId" : dccarId
    }
  })
}


export const updateCar = (carData) => {
  return axios.request({
    url: '/updateCarById',
    method: 'post',
    data: {
      dccarId: carData.dccarId,
      dccarLicense: carData.dccarLicense,
      dccarAutomaker: carData.dccarAutomaker,
      dccarRemark: carData.dccarRemark,
      createTime: carData.createTime
    },
  })
}

export const deleteCarById = (dccarId) => {
  return axios.request({
    url: '/deleteCarById',
    method: 'get',
    params: {
      "dccarId" : dccarId
    }
  })
}


export const getOrganizationStructure = (query) => {
  return axios.request({
    url: '/getOrganizationStructure',
    method: 'post',
    data: {
      departmentName: query.name,
      status: query.status,
      page: query.page,
      limit: query.limit
    }
  })
}


export const updateDepartment = (formItem) => {
  return axios.request({
    url: '/updateDepartment',
    method: 'post',
    data: {
      corganCode: formItem.corganCode,
      corganName: formItem.corganName,
      mainPerson: formItem.mainPerson
    },
  })
}


export const deleteDepartmentById = (corganCode) => {
  return axios.request({
    url: '/deleteDepartmentById',
    method: 'post',
    data: {
      "corganCode" : corganCode
    },
  })
}


export const updateEmployeeRole = (formItem) => {
  return axios.request({
    url: '/updateEmployeeRole',
    method: 'post',
    data: {
      account : formItem.account,
      uroleId : formItem.uroleId
    },
  })
}

export const getRolePermission = (roleQuery) => {
  return axios.request({
    url: '/getRolePermission',
    method: 'post',
    data: {
      role : roleQuery.role,
      // permission: roleQuery.permission
    },
  })
}

export const updateRolePermission = (roleQuery) => {
  return axios.request({
    url: '/updateRolePermission',
    method: 'post',
    data: {
      role : roleQuery.role,
      permission: roleQuery.permission
    },
  })
}

export const addNewCar = (carData) => {
  return axios.request({
    url: '/addNewCar',
    method: 'post',
    data: {
      dccarLicense : carData.dccarLicense,
      dccarAutomaker: carData.dccarAutomaker,
      dccarRemark: carData.dccarRemark,
      dccarStatus: carData.dccarStatus
    },
  })
}

export const getDriverRecordList = (queryData) => {
  return axios.request({
    url: '/getDriverRecordList',
    method: 'post',
    data: {
      name : queryData.name,
      account: queryData.account,
      udrecordStart: queryData.start,
      udrecordEnd: queryData.end,
      page: queryData.page,
      limit:queryData.limit
    },
  })
}

export const getAllViolationType = () => {
  return axios.request({
    url: '/getAllViolationType',
    method: 'get',
  })
}

export const getViolationRecordList = (queryData) => {
  return axios.request({
    url: '/getViolationRecordList',
    method: 'post',
    data: {
      name : queryData.name,
      account: queryData.account,
      startTime: queryData.start,
      endTime: queryData.end,
      udvtype_id: queryData.type,
      page: queryData.page,
      limit:queryData.limit
    },
  })
}

export const getErrorAppealSolutionList = (queryData) => {
  return axios.request({
    url: '/getErrorAppealSolutionList',
    method: 'post',
    data: {
      actionType : queryData.actionType,
      violateType: queryData.violateType,
      account: queryData.account,
      page: queryData.page,
      limit:queryData.limit
    },
  })
}

export const getViolationImage = (id) => {
  return axios.request({
    url: '/getViolationImage',
    method: 'get',
    params: {
      recordId:id
    },
    responseType:"arraybuffer"
  })
}

export const downloadViolationImage = (id) => {
  return axios.request({
    url: '/downloadViolationImage',
    method: 'get',
    params: {
      recordId:id
    },
    // responseType:"arraybuffer"
  })
}

export const deleteViolationRecord = (id) => {
  return axios.request({
    url: '/deleteViolationRecord',
    method: 'get',
    params: {
      recordId:id
    },
  })
}

export const sendFeedbackInformation = (id,msg) => {
  return axios.request({
    url: '/sendFeedbackInformation',
    method: 'post',
    data: {
      ueappealId:id,
      message: msg
    }
  })
}

export const getUserInfoByAccount = (account) => {
  return axios.request({
    url: '/getUserInfoByAccount',
    method: 'post',
    data: {
      account: account
    }
  })
}

export const getAllDriveViolationByDriverRecordId = (recordId) => {
  return axios.request({
    url: '/getAllDriveViolationByDriverRecordId',
    method: 'get',
    params: {
      recordId: recordId
    }
  })
}

export const getHealthRecordList = (queryData) => {
  return axios.request({
    url: '/getHealthRecordList',
    method: 'post',
    data: {
      page: queryData.page,
      limit: queryData.limit,
      startTime: queryData.start,
      endTime: queryData.end,
      employeeName: queryData.name,
      employeeId: queryData.account,
    }
  })
}

export const sendMessage = (messageData) => {
  return axios.request({
    url: '/sendMessage',
    method: 'post',
    data: {
      account: messageData.account,
      message: messageData.message,
    }
  })
}

export const getViolationRecordsSum = (query) => {
  return axios.request({
    url: '/getViolationRecordsSum',
    method: 'post',
    data: {
      account: query.account,
      name: query.name,
      startTime: query.start,
      endTime: query.end
    }
  })
}


export const uploadHonorForm = (formData) => {
  return axios.request({
    url: '/uploadHonorForm',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export const addHonorType = (formData) => {
  return axios.request({
    url: '/addHonorType',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export const getHonorByName = (queryData) => {
  return axios.request({
    url: '/getHonorByName',
    method: 'post',
    data: queryData
  })
}

export const deleteHonorById = (honorId) => {
  return axios.request({
    url: '/deleteHonorById',
    method: 'post',
    data: {
      honorId: honorId
    }
  })
}

export const getHonorRelationshipList = (queryData) => {
  return axios.request({
    url: '/getHonorRelationshipList',
    method: 'post',
    data: queryData
  })
}

//getAllHonorType
export const getAllHonorType = () => {
  return axios.request({
    url: '/getAllHonorType',
    method: 'post'
  })
}

export const addHonorRelation = (Data) => {
  return axios.request({
    url: '/addHonorRelation',
    method: 'post',
    data: Data
  })
}

export const deleteHonorRelation = (relationId) => {
  return axios.request({
    url: '/deleteHonorRelation',
    method: 'post',
    data: {
      relationId: relationId
    }
  })
}


export const getErrorViolation = (queryData) => {
  return axios.request({
    url: '/getErrorViolation',
    method: 'post',
    data: queryData
  })
}

export const deleteCompleteRecord = (recordId) => {
  return axios.request({
    url: '/deleteCompleteRecord',
    method: 'post',
    data: {
      recordId: recordId
    }
  })
}

export const getViolationSumData = () => {
  return axios.request({
    url: '/getViolationSumData',
    method: 'post',
    data: {
    }
  })
}

//getViolationDayNum
export const getViolationDayNum = (queryData) => {
  return axios.request({
    url: '/getViolationDayNum',
    method: 'post',
    data: queryData
  })
}

//updateHonorById
export const updateHonorById = (queryData) => {
  return axios.request({
    url: '/updateHonorById',
    method: 'post',
    data: queryData
  })
}

export const getApplyListByQuery = (queryData) => {
  return axios.request({
    url: '/getApplyListByQuery',
    method: 'post',
    data: queryData
  })
}

//updateApplyRecord
export const updateApplyRecord = (queryData) => {
  return axios.request({
    url: '/updateApplyRecord',
    method: 'post',
    data: queryData
  })
}

export const getVideoImg = () => {
  return axios.request({
    url: '/getVideoImg',
    method: 'post',
  })
}
